<template>
  <div class="pc-qrcode" v-if="qrcodeList.length&&show">
    <div class="pc-qrcode-box pc-qrcode-box-3" :class="{'pc-qrcode-box-1':qrcodeList.length===1,'pc-qrcode-box-2':qrcodeList.length===2,'pc-qrcode-box-3':qrcodeList.length===3}">
      <div class="pc-qrcode-item" v-for="item in qrcodeList" :key="item.url">
        <img :src="item.url" class="qc-qrcode-img" alt="">
        <div class="pc-qrcode-text">
          <div class="pc-qrcode-title">{{item.title}}</div>
          <div class="pc-qrcode-content">{{item.content}}</div>
        </div>
      </div>
    </div>
    <div class="pc-qrcode-close" @click="show=false">
      <img src="../assets/img/pc-qrcode-close.png" alt="">
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import consts from '../common/consts'
export default {
  data() {
    return {
      show: false
    }
  },
  computed: {
    ...mapState({
      qrcodeList: s => s.qrcodeList
    })
  },
  watch: {
    qrcodeList(val) {
      if (val.length) {
        this.startToShow()
      }
    }
  },
  mounted() {
    if (this.qrcodeList.length) {
      this.startToShow()
    }
  },
  methods: {
    startToShow() {
      if (this.$getDeviceInfo().isPhone || document.documentElement.getBoundingClientRect().width < 560) {
        return
      }
      if (this.qrcodeList.length) {
        this.show = true
      }
    }
  }
}
</script>

<style scoped lang="scss">
.pc-qrcode {
  position: fixed;
  top: 60px;
  left: 20px;
  z-index: 88;
}
.pc-qrcode-box {
  text-align: center;
  img {
    display: block;
    width: 135px;
    height: 135px;
    margin: auto;
  }
  .weixin-img {
    margin-top: 35px;
  }
  .app-img {
  }
}
.pc-qrcode-box-3 {
  width: 261px;
  height: 807px;
  padding-top: 169px;
  background: url(../assets/img/pc-qrcode-3.png) center no-repeat;
  background-size: contain;
}
.pc-qrcode-box-2 {
  width: 261px;
  height: 612px;
  padding-top: 184px;
  background: url(../assets/img/pc-qrcode-2.png) center no-repeat;
  background-size: contain;
}
.pc-qrcode-box-1 {
  width: 261px;
  height: 396px;
  padding-top: 184px;
  background: url(../assets/img/pc-qrcode-1.png) center no-repeat;
  background-size: contain;
  .weixin-img {
    margin-top: 0;
  }
}
.pc-qrcode-close {
  position: absolute;
  bottom: -8px;
  right: -23px;
  width: 40px;
  height: 40px;
  img {
    width: 100%;
    height: 100%;
  }
}
.pc-qrcode-item {
  margin-bottom: 34px;
}
.pc-qrcode-text {
  margin-top: 8px;
  color: #333;
}
.pc-qrcode-title {
  font-size: 16px;
  font-weight: bold;
}
.pc-qrcode-content {
  font-size: 13px;
}
</style>
